class Solution {
public:
    int findDuplicate(vector<int>& nums) 
    {
        //快慢指针假设循环链表解决；
        int slow = 0;
        int fast = 0;
        int n = nums.size();
        while(true)
        {
            slow = nums[slow];
            fast = nums[nums[fast]];
            if(fast == slow)
            {
                break;
            }
        }
        int ret = 0;
        while(true)
        {
            ret = nums[ret];
            slow = nums[slow];
            if(ret == slow)
            {
                break;
            }
        }
        return ret;
    }
};